/*
 * ProblemReader.java
 *
 * Created on 9 de noviembre de 2006, 03:46 PM
 */

package cflp;

/**
 *
 * @author tavobula
 */
public class ProblemReader {
    
    private int nodesNumber;
    private int arcsNumber;
    private int[] demand;
    private int[][] distances;
    private int[] warehouseCapacity;
    private int[][] costs;
    private int[] fixedCosts;
    
    
    /** Creates a new instance of ProblemReader */
    public ProblemReader(String name) {
        readProblem(name);
    }
    
    public void readProblem(String name){
        try{
            java.io.FileReader i= new java.io.FileReader(new java.io.File(name));
            java.io.BufferedReader br=new java.io.BufferedReader(i);
            String s="";
            s=br.readLine();
            java.util.StringTokenizer str;
            str=new java.util.StringTokenizer(s);
            //Se leen el número de nodos
            nodesNumber = Integer.parseInt(str.nextToken());
            //Se leen el número de arcos
            s=br.readLine();
            str=new java.util.StringTokenizer(s);
            arcsNumber=Integer.parseInt(str.nextToken());
            //Se leen las demandas
            demand=new int[nodesNumber];
            s=br.readLine();
            s=br.readLine();
            for(int k=0;k<nodesNumber;++k){
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                str.nextToken();
                String a=str.nextToken();
                demand[k]=Integer.parseInt(a);
            }
            //Se leen las capacidades
            warehouseCapacity=new int[nodesNumber];
            s=br.readLine();
            s=br.readLine();
            for(int k=0;k<nodesNumber;++k){
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                str.nextToken();
                warehouseCapacity[k]=Integer.parseInt(str.nextToken());
            }
            //Se leen los costos fijos
            fixedCosts=new int[nodesNumber];
            s=br.readLine();
            s=br.readLine();
            for(int k=0;k<nodesNumber;++k){
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                str.nextToken();
                fixedCosts[k]=Integer.parseInt(str.nextToken());
            }
            //Se leen las distancias
            distances=new int[nodesNumber][nodesNumber];
            s=br.readLine();
            s=br.readLine();            
            for(int k=0;k<nodesNumber;++k){
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                for (int j=0;j<nodesNumber;++j){
                    String a=str.nextToken();
                    distances[k][j]=Integer.parseInt(a);
                }
            }
            //Se leen los costos
            costs=new int[nodesNumber][nodesNumber];
            s=br.readLine();
            s=br.readLine();
            for(int k=0;k<nodesNumber;++k){
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                for (int j=0;j<nodesNumber;++j){
                    String a=str.nextToken();
                    costs[k][j]=Integer.parseInt(a);
                }
            }
            System.out.println("se leyo el archivo");
            br.close();
        }catch(Exception e){
            System.out.println("ERROR LECTURA");
            System.out.println(e.getMessage()+" "+e.getCause());
        }
    }

    
     public int getNodesNumber() {
        return nodesNumber;
    }
    
    public int[] getDemand() {
        return demand;
    }

    public int[][] getDistances() {
        return distances;
    }

    public int[] getWarehouseCapacity() {
        return warehouseCapacity;
    }

    public int[][] getCosts() {
        return costs;
    }

    public int[] getFixedCosts() {
        return fixedCosts;
    }

    public int getArcsNumber() {
        return arcsNumber;
    }
}

